<?php

class Account extends Controller {

	function Welcome()
	{
		parent::Account();	
	}

	function register()
	{
		if($_POST)
		{
			$email = $this->input->post('email', FALSE);
			$password = $this->input->post('password', FALSE);
			$nickname = $this->input->post('nickname');
			
			// 加载表单验证类
			$this->load->library('form_validation');
			$this->form_validation->set_rules('email', '邮箱地址', 'trim|valid_email|required');
			$this->form_validation->set_rules('password', 'Password', 'trim|required|max_length[50]|min_length[6]|md5');

			if($this->form_validation->run() == FALSE)
			{
				exit('error' . validation_errors());
			}
			$password = md5($password);

			$user = array(
				'Email' => $email, 
				'Password' => $password, 
				'Nickname' => $nickname,
				'RegTime' => time(),
				'RegIP' => $this->input->ip_address()
			);

			$this->load->model('UserModel');
			print_r($this->UserModel->add($user));
		}
		else
		{
			$this->load->view('register');
		}
	}
	
	function view()
	{
		$this->load->model('MblogModel');
		$mblog = $this->MblogModel->getMblog(3);
		print_r($mblog);
	}
}

/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */